blob: e56085992306eb3ed143998af7c3fccd4aadf01f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
---
import Show from '../../components/Show.astro';
import Layout from '../../layouts/Layout.astro';
import fetchAPI from '../../lib/api';
import type { IUser } from '../../types.js';
const { id } = Astro.params as { id: string };
const user = (await fetchAPI(`user/${id}`)) as IUser;
---
<Layout>
<main>
<Show when={user}>
<Show when={!user.error}>
<h1 slot="fallback">User not found.</h1>
<h1>User : {user.id}</h1>
<ul class="meta">
<li>
<span class="label">Created:</span>
{user.created}
</li>
<li>
<span class="label">Karma:</span>
{user.karma}
</li>
<Show when={user.about}>
<li set:html={user.about} class="about" />{' '}
</Show>
</ul>
<p>
<a href={`https://news.ycombinator.com/submitted?id=${user.id}`}>submissions</a> |{' '}
<a href={`https://news.ycombinator.com/threads?id=${user.id}`}>comments</a>
</p>
</Show>
</Show>
</main>
</Layout>
<style>
main {
background-color: rgb(248 250 252);
box-sizing: border-box;
padding: 2em 3em;
}
h1 {
margin: 0;
font-size: 1.5em;
}
.meta {
list-style-type: none;
padding: 0;
}
.label {
display: inline-block;
min-width: 4em;
}
.about {
margin: 1em 0;
}
p a {
text-decoration: underline;
}
</style>
|